<template>
  <!-- 访客记录-----访客记录 -->
  <div class="visitor-index">
    <a-row class="aRow-wrapper" :gutter="12">
      <a-col class="listContent-wrapper">
        <top-title :updateTime="true" :content="content"></top-title>
        <div class="click-btn" v-if="activeKey == 1" @click="showAddModal">添加备案企业</div>
        <div class="l-w_content">
          <div class="tabsList">
            <a-tabs class="tabs" v-model="activeKey" @tabClick="handelClick">
              <a-tab-pane key="1" tab="备案企业">
                <filing-enterprise v-if="activeKey == 1" ref="filingEnterprise"></filing-enterprise>
              </a-tab-pane>
              <a-tab-pane key="2" tab="退出备案企业">
                <filing-enterprise-exit v-if="activeKey == 2"></filing-enterprise-exit>
              </a-tab-pane>
            </a-tabs>
          </div>
        </div>
      </a-col>
    </a-row>
  </div>
</template>
<script>
import topTitle from '@/components/topTitle'
import filingEnterprise from './filingEnterprise'
import filingEnterpriseExit from './filingEnterpriseExit'
import { findEnableDictItemsbyCode } from '@/api/api'

export default {
  name: 'visitor-index',
  components: { topTitle, filingEnterprise, filingEnterpriseExit },
  data() {
    return {
      content: [['备案管理']],
      activeKey: '1',
      key: '',
    }
  },
  mounted() {
    this.activeKey = localStorage.getItem('filingManagementActiveKey') || '1'
    this.getDict()
  },
  methods: {
    async getDict() {
      let { result } = await findEnableDictItemsbyCode({ code: 'factory_monitoring_type' })
      localStorage.setItem('factoryMonitoringType', JSON.stringify(result))
    },

    handelClick(event) {
      this.activeKey = event
      localStorage.setItem('filingManagementActiveKey', this.activeKey)
    },

    showAddModal() {
      this.$refs.filingEnterprise.showaddFactoryModel()
    },
  },
}
</script>
<style lang="less" scoped>
.visitor-index {
  width: 100%;
  height: 100%;
  .aRow-wrapper {
    // padding-top: 0;
    position: relative;
  }

  .click-btn {
    position: absolute;
    top: 0;
    right: 0;
    cursor: pointer;
    width: 1.2rem;
    height: 0.4rem;
    line-height: 0.4rem;
    text-align: center;
    background: #00f8ff;
    border-radius: 4px;

    font-size: 0.14rem;
    font-family: PingFang SC-Bold, PingFang SC;
    font-weight: bold;
    color: #023234;
  }
}
</style>
